/*
 * AssignMeterDataBO.java 
 * 
 * Copyright 2009 Wangfeng Beijing Inc. 
 * All rights reserved. 
 * 
 * Created on 2012-07-11
 */

package com.bjtech.domain.query;

import java.util.Date;
import com.bjtech.web.util.SelectBean;
import org.ssi.web.util.QuerySpecTpl;

/**
 * 功能概述:分摊数据 <br>
 * 
 * @author 王峰
 */

public class AssignMeterDataQuerySpec extends SelectBean {
	/* */
	private Long id;
	/* */
	private String serious_num;
	/* */
	private Long read_num;
	/* */
	private Date read_time;
	private Date b_read_time;
	private Date e_read_time;
	/* */
	private Float back_temp;
	/* */
	private Float from_temp;
	/* */
	private Date record_time;
	private Date b_record_time;
	private Date e_record_time;
	/* */
	private Long last_year_num;
	/* */
	private Long january;
	/* */
	private Long february;
	/* */
	private Long march;
	/* */
	private Long april;
	/* */
	private Long may;
	/* */
	private Long october;
	/* */
	private Long november;
	/* */
	private Long december;
	
	private String jzq_num;
	
	private Long area_id;
	
	private String start_date;
	
	private String zh_record_date;
	private String record_date;
	
	private String zh_jzq_num;
	
	private Date max_read_time;

	@Override
	public void queryParamString() {
		StringBuilder fromPart = new StringBuilder(" where right(serious_num,3)!='000'");

		if (this.isAll != null && this.isAll.intValue() != 1) {
			if (QuerySpecTpl.isValid(id)) {
				fromPart.append(" and a.id = ");
				fromPart.append(id);
			}

			if (QuerySpecTpl.isValid(serious_num)) {
				fromPart.append(" and a.serious_num = ");
				fromPart.append(serious_num);
			}

			if (QuerySpecTpl.isValid(read_num)) {
				fromPart.append(" and a.read_num = ");
				fromPart.append(read_num);
			}
			if (QuerySpecTpl.isValid(area_id)) {
				fromPart.append(" and a.serious_num in (select serious_num from P_ASSIGN_METER_INFO where area_id= ");
				fromPart.append(area_id);
				fromPart.append(" ) ");
			}
			
			if (QuerySpecTpl.isValid(read_time)) {
				fromPart
						.append(" and str_to_date(a.read_time,'%Y-%m-%d')=str_to_date(CONCAT(''',");
				fromPart.append(read_time);
				fromPart.append(",'''),'%Y-%m-%d')");
			}
			if (QuerySpecTpl.isValid(b_read_time)) {
				fromPart
						.append(" and str_to_date(a.read_time,'%Y-%m-%d')>=str_to_date(CONCAT(''',");
				fromPart.append(b_read_time);
				fromPart.append(",'''),'%Y-%m-%d')");
			}
			if (QuerySpecTpl.isValid(e_read_time)) {
				fromPart
						.append(" and str_to_date(a.read_time,'%Y-%m-%d')<=str_to_date(CONCAT(''',");
				fromPart.append(e_read_time);
				fromPart.append(",'''),'%Y-%m-%d')");
			}

			if (QuerySpecTpl.isValid(back_temp)) {
				fromPart.append(" and a.back_temp = ");
				fromPart.append(back_temp);
			}

			if (QuerySpecTpl.isValid(from_temp)) {
				fromPart.append(" and a.from_temp = ");
				fromPart.append(from_temp);
			}

			if (QuerySpecTpl.isValid(record_time)) {
				fromPart
						.append(" and str_to_date(a.record_time,'%Y-%m-%d')=str_to_date(CONCAT(''',");
				fromPart.append(record_time);
				fromPart.append(",'''),'%Y-%m-%d')");
			}
			if (QuerySpecTpl.isValid(b_record_time)) {
				fromPart
						.append(" and str_to_date(a.record_time,'%Y-%m-%d')>=str_to_date(CONCAT(''',");
				fromPart.append(b_record_time);
				fromPart.append(",'''),'%Y-%m-%d')");
			}
			if (QuerySpecTpl.isValid(e_record_time)) {
				fromPart
						.append(" and str_to_date(a.record_time,'%Y-%m-%d')<=str_to_date(CONCAT(''',");
				fromPart.append(e_record_time);
				fromPart.append(",'''),'%Y-%m-%d')");
			}

			if (QuerySpecTpl.isValid(last_year_num)) {
				fromPart.append(" and a.last_year_num = ");
				fromPart.append(last_year_num);
			}

			if (QuerySpecTpl.isValid(january)) {
				fromPart.append(" and a.january = ");
				fromPart.append(january);
			}

			if (QuerySpecTpl.isValid(february)) {
				fromPart.append(" and a.february = ");
				fromPart.append(february);
			}

			if (QuerySpecTpl.isValid(march)) {
				fromPart.append(" and a.march = ");
				fromPart.append(march);
			}

			if (QuerySpecTpl.isValid(april)) {
				fromPart.append(" and a.april = ");
				fromPart.append(april);
			}

			if (QuerySpecTpl.isValid(may)) {
				fromPart.append(" and a.may = ");
				fromPart.append(may);
			}

			if (QuerySpecTpl.isValid(october)) {
				fromPart.append(" and a.october = ");
				fromPart.append(october);
			}

			if (QuerySpecTpl.isValid(november)) {
				fromPart.append(" and a.november = ");
				fromPart.append(november);
			}

			if (QuerySpecTpl.isValid(december)) {
				fromPart.append(" and a.december = ");
				fromPart.append(december);
			}
			
			if (QuerySpecTpl.isValid(jzq_num)) {
				fromPart.append(" and a.jzq_num = '");
				fromPart.append(jzq_num);
				fromPart.append("'");
			}
			
			if (QuerySpecTpl.isValid(start_date)) {
				fromPart.append(" and date_format(a.record_time,'%Y-%m-%d')='");
				fromPart.append(start_date);
				fromPart.append("'");
			}
			
			if (QuerySpecTpl.isValid(record_date)) {
				fromPart.append(" and date_format(a.record_time,'%Y-%m-%d')='");
				fromPart.append(record_date);
				fromPart.append("'");
			}
		}
		super.setQueryString(fromPart.toString());
	}

	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getSerious_num() {
		return this.serious_num;
	}

	public void setSerious_num(String serious_num) {
		this.serious_num = serious_num;
	}

	public Long getRead_num() {
		return this.read_num;
	}

	public void setRead_num(Long read_num) {
		this.read_num = read_num;
	}

	public Date getRead_time() {
		return this.read_time;
	}

	public void setRead_time(Date read_time) {
		this.read_time = read_time;
	}

	public Date getB_read_time() {
		return this.b_read_time;
	}

	public void setB_read_time(Date b_read_time) {
		this.b_read_time = b_read_time;
	}

	public Date getE_read_time() {
		return this.e_read_time;
	}

	public void setE_read_time(Date e_read_time) {
		this.e_read_time = e_read_time;
	}

	public Float getBack_temp() {
		return this.back_temp;
	}

	public void setBack_temp(Float back_temp) {
		this.back_temp = back_temp;
	}

	public Float getFrom_temp() {
		return this.from_temp;
	}

	public void setFrom_temp(Float from_temp) {
		this.from_temp = from_temp;
	}

	public Date getRecord_time() {
		return this.record_time;
	}

	public void setRecord_time(Date record_time) {
		this.record_time = record_time;
	}

	public Date getB_record_time() {
		return this.b_record_time;
	}

	public void setB_record_time(Date b_record_time) {
		this.b_record_time = b_record_time;
	}

	public Date getE_record_time() {
		return this.e_record_time;
	}

	public void setE_record_time(Date e_record_time) {
		this.e_record_time = e_record_time;
	}

	public Long getLast_year_num() {
		return this.last_year_num;
	}

	public void setLast_year_num(Long last_year_num) {
		this.last_year_num = last_year_num;
	}

	public Long getJanuary() {
		return this.january;
	}

	public void setJanuary(Long january) {
		this.january = january;
	}

	public Long getFebruary() {
		return this.february;
	}

	public void setFebruary(Long february) {
		this.february = february;
	}

	public Long getMarch() {
		return this.march;
	}

	public void setMarch(Long march) {
		this.march = march;
	}

	public Long getApril() {
		return this.april;
	}

	public void setApril(Long april) {
		this.april = april;
	}

	public Long getMay() {
		return this.may;
	}

	public void setMay(Long may) {
		this.may = may;
	}

	public Long getOctober() {
		return this.october;
	}

	public void setOctober(Long october) {
		this.october = october;
	}

	public Long getNovember() {
		return this.november;
	}

	public void setNovember(Long november) {
		this.november = november;
	}

	public Long getDecember() {
		return this.december;
	}

	public void setDecember(Long december) {
		this.december = december;
	}

	public String getJzq_num() {
		return jzq_num;
	}

	public void setJzq_num(String jzqNum) {
		jzq_num = jzqNum;
	}

	public Long getArea_id() {
		return area_id;
	}

	public void setArea_id(Long areaId) {
		area_id = areaId;
	}

	public String getStart_date() {
		return start_date;
	}

	public void setStart_date(String startDate) {
		start_date = startDate;
	}

	public String getZh_record_date() {
		return zh_record_date;
	}

	public void setZh_record_date(String zhRecordDate) {
		zh_record_date = zhRecordDate;
	}

	public String getZh_jzq_num() {
		return zh_jzq_num;
	}

	public void setZh_jzq_num(String zhJzqNum) {
		zh_jzq_num = zhJzqNum;
	}

	public String getRecord_date() {
		return record_date;
	}

	public void setRecord_date(String recordDate) {
		record_date = recordDate;
	}

	public Date getMax_read_time() {
		return max_read_time;
	}

	public void setMax_read_time(Date maxReadTime) {
		max_read_time = maxReadTime;
	}
}
